using namespace std;

#include "Messenger.hh"

Messenger::Messenger() {
	photonCount = 0;
	numHits = 0;
	numEvents = 0;
	spectrum = new int[200];
	for (int i = 0; i < 200; i++)
		spectrum[i] = 0;
}

Messenger::~Messenger() {
	delete spectrum;
}

void Messenger::AddToPhotonCount() {
	photonCount++;
}

void Messenger::resetCounts() {
	photonCount = 0;
	numHits = 0;
	numEvents = 0;
	delete spectrum;
	spectrum = new int[200];
	for (int i = 0; i < 200; i++)
		spectrum[i] = 0;
}

int Messenger::PhotonCount() {
	return photonCount;
}

void Messenger::AddHits(int n) {
	numHits += n;
	numEvents += 1;
	if (n < 200)
		spectrum[n]++;
}

double Messenger::GetAverageNumHits() {
	return ((double) numHits) / ((double) numEvents);
}

int* Messenger::getSpectrum() {
	return spectrum;
}

int Messenger::getNumEvents() {
	return numEvents;
}
